package domain;

import java.sql.SQLException;

import database.access.layer.MovieDal;

public class Movie {
	 MovieDescription movieDescription; 
	
	public Movie(int movieId ,String name, String description) {
		this.movieDescription = new MovieDescription(movieId, name, description);
	}

	public MovieDescription getMovieDescription() {
		return movieDescription;
	}

	public void setMovieDescription(MovieDescription movieDescription)
			throws Exception {
		if (movieDescription == null) {
			throw (new Exception("Null Object: Cannot set MovieDescryption"));
		} else {
			this.movieDescription = movieDescription;
		}
	}
	
	public static Movie search(String movieName) throws SQLException{
		MovieDal movieDal = new MovieDal();
		return movieDal.findMovieByName(movieName);
		
	}
	
	public static Movie searchById(int movieId) throws SQLException{
		MovieDal movieDal = new MovieDal();
		return movieDal.findMovieById(movieId);
		
	}

}
